var arr = [5, 8, 10, 3, 2, 18, 17, 9];
shellSort(arr);
// console.log(shellSort(arr))
function shellSort (arr) {
    let length  = arr.length
    for (var gap = Math.floor(length/2); gap > 0; gap = Math.floor(gap/2)) {
       for (let i = gap; i < arr.length; i++) {
           var  j = i;
           var  current = arr[i]
           while(j-gap >= 0 && current < arr[j-gap]) {
               arr[j] = arr[j-gap]
               j = j- gap 
           }
           arr[j] = current;
           
       }
        
    }
    return arr
}